package com.example.demo.utils;

import com.alibaba.fastjson.JSON;

public class Result {
    private String message;
    private Object data;

    public static String success() {
        return JSON.toJSONString(new Result("success", null));
    }

    public static String success(Object data) {
        return JSON.toJSONString(new Result("success", data));
    }

    public static String error(String message) {
        return JSON.toJSONString(new Result(message, null));
    }

    public static String error() {
        return Result.error("error");
    }

    public Result(String message, Object data) {
        this.message = message;
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
